package com.example.demo.quant;

import com.example.demo.entity.Race;
import com.example.demo.mapper.RaceLogMapper;
import com.example.demo.mapper.RaceMapper;
import com.example.demo.quant.impl.QuantContextImpl;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.time.LocalDateTime;

@Slf4j
@Data
public class QuantEngine {
    private RaceMapper raceMapper;

    private RaceLogMapper raceLogMapper;

    public void runRace(QuantRace quantRace) {
        for (int i = 0; i <= quantRace.getRound(); i++) {
            DataMetric dataMetric = quantRace.getDataProvider().metric();

            QuantContextImpl context = new QuantContextImpl(quantRace, this.raceLogMapper);
            quantRace.getStrategy().decision(dataMetric, context);

            quantRace.getDataProvider().skip(quantRace.getPeriod());
        }

        log.warn("#18 run end, quantRace=" + quantRace);
    }
}
